import { ApiProperty } from '@nestjs/swagger';
import { ValidateIf, IsOptional,IsEmail ,IsString} from 'class-validator';
import { UserDto } from './user.dto';

export class CreateUserDto extends UserDto{
  // 不是必填的参数可以封装到一起
  @ApiProperty({ required: true, description: '邮箱' ,name:'email'})
  @IsEmail({}, { message: '邮箱格式错误' })
  @IsString({ message: '邮箱必须为字符类型' })
  @ValidateIf((o) => o.email != '')
  @IsOptional()
  readonly email: string;
}